package net.api;

public class InetAddress {
    public static void main(String[] args) throws Exception {
        java.net.InetAddress localHost = java.net.InetAddress.getLocalHost();
        java.net.InetAddress host = java.net.InetAddress.getByName("www.baidu.com");
//        getnet(host);
        boolean reachable = host.isReachable(6000);
        System.out.println(reachable);
    }

    private static void getnet(java.net.InetAddress localHost) {
        String hostName = localHost.getHostName();
        String hostAddress = localHost.getHostAddress();
        System.out.println("主机名"+hostName+"ip地址"+hostAddress);
    }

}
